package com.central.apps.handler;

import com.central.app.common.util.BLuntil;
import com.central.app.service.HandlerService;
import com.central.apps.handler.base.LvBaseHandler;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/*
* 试验记录
* */
@Component
public class TestRecordHandler extends LvBaseHandler {
    @Autowired
    private HandlerService handlerService;
    @Override
    public Object operate(String app, String type, Map<String, Object> params) throws Exception {
        HashMap<String,Object> result=new HashMap<String, Object>() ;
        result.put("code",1);
        result.put("resp_msg","操作失败");
        //试验记录app
        if("testrecordApp".equals(app)){
            //根据选择试验标准编号，带出试验标准的所有信息（主表和子表）
            if ("getAllTeststandard".equals(type)){
                //获取到试验标准编号
                String teststandardnum = MapUtils.getString(params, "teststandardnum");
                //获取试验标准列表
                String sql="  SELECT a.teststandardname teststandardname,b.*  from  bl_teststandard a " +
                        "  LEFT JOIN bl_teststandardline b ON a.teststandardnum=b.teststandardnum  " +
                        "  WHERE a.teststandardnum='"+teststandardnum+"'";
                return BLuntil.toPage(params, handlerService, sql);

            }
        }

        return super.operate(app, type, params);
    }
}
